﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CozeDto.AdminDtos;
using CozeDto.Base;
using FluentValidation;

namespace CozeDto.UserDtos
{
    /// <summary>
    ///数据校验类要继承自 AbstractValidator
    ///通过 AbstractValidator 的泛型参数指定对哪个类进行校验
    /// </summary>
    public class ReqAddUserValidator : AbstractValidator<ReqAddUser>
    {
        /// <summary>
        /// 校验规则写到校验类的构造方法中
        /// </summary>
        public ReqAddUserValidator()
        {
            // 通过RuleFor来指定要对哪个属性进行校验
            // 多个校验规则可以采用链式调用的写法
            // 每个需要校验的属性对应一组RuleFor调用
            RuleFor(x => x.Account).NotNull().WithMessage("账号不可为空");
            //RuleFor(x => x.Roles).NotNull().WithMessage("所属角色不可为空");

            // 通过RuleFor来指定要对哪个属性进行校验
            // 多个校验规则可以采用链式调用的写法
            // 每个需要校验的属性对应一组RuleFor调用
            //RuleFor(x => x.Email)
            //    .EmailAddress()
            //    // 在Must方法中编写自定义校验规则，
            //    .Must(v => v.EndsWith("@qq.com") || v.EndsWith("@163.com"))
            //    // 通过WithMessage方法自定义报错信息，
            //    // WithMessage方法设置的报错信息只作用于它之前的那个校验规则
            //    .WithMessage("只支持QQ和163邮箱");

            RuleFor(x => x.Pwd)
                .NotNull()
                .Length(6, 18).WithMessage("密码长度必须介于6到18之间")
                .Equal(x => x.PasswordConfirm).WithMessage("两次密码必须一致");

            //RuleFor(x => x.Name).NotNull().Length(3, 10)
            //    .WithMessage("用户名必须3到10位");
            //RuleFor(x => x.Email).NotNull().EmailAddress()
            //    .Must(x => x.EndsWith("@163.com") || x.EndsWith("@qq.com"))
            //    .WithMessage("必须是163或qq邮箱");
            //RuleFor(x => x.Password1).NotNull().Length(5, 10)
            //    .WithMessage("密码长度为5到10")
            //    .Equal(x => x.Password2).WithMessage("两次密码必须相等"); 
        }
    }
    public class ReqAddUser : BaseAddModel
    {
       
        /// <summary>
        /// 密码
        /// </summary> 
        public string? Pwd { get; set; }

        /// <summary>
        /// 二次密码确认
        /// </summary>
        public string? PasswordConfirm { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string? Phone { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        public string? Account { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string? Avatar { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        public string? NickName { get; set; }

        /// <summary>
        /// 微信账户
        /// </summary>
        public string? WeChartAccount { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string? Email { get; set; }

        /// <summary>
        /// 用户类型 (普通用户/分销用户)
        /// </summary>
        public string? UserType { get; set; }

        /// <summary>
        /// 分销用户ID
        /// </summary>
        public string? SaleUserId { get; set; }

        /// <summary>
        /// 消费额设定
        /// </summary>
        public double? ConsumptionAmountLimit { get; set; }

        /// <summary>
        /// 返现设定
        /// </summary>
        public double? CashbackAmountLimit { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public string? Gender { get; set; }
         
        /// <summary>
        /// 生日
        /// </summary>
        public string? Birthday { get; set; }

        /// <summary>
        /// 地区
        /// </summary>
        public string? Region { get; set; }

        /// <summary>
        /// 签名
        /// </summary>
        public string? Signature { get; set; }

        /// <summary>
        /// 收款二维码设定（针对分销员）
        /// </summary>
        public string? WxQrCode { get; set; }

        /// <summary>
        /// 支付宝收款二维码设定（针对分销员）
        /// </summary>
        public string? AlipayQrCode { get; set; }

        /// <summary>
        /// 分销链接（offlne根据申请沟通，沟通后后台变更用户类型为分销员，该用户前端UI即可看见分销链接
        /// </summary>
        public string? SalesLink { get; set; }

        /// <summary>
        /// 账户金额
        /// </summary>
        public double? Balance { get; set; }

        /// <summary>
        /// 上次登录时间
        /// </summary>
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 上次登录IP地址 
        /// </summar
        public string? LastLoginIp { get; set; }

        /// <summary>
        /// 登录总次数
        /// </summary>
        public int? LoginTotalCount { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public bool? Status { get; set; }
    }
}
